import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { showToast, closeToast } from 'vant'
import 'vant/es/toast/style'
import axios from "axios";
// import axios from 'axios'

import App from './App.vue'
import router from './router'
import {
    Button,
    Tabbar,
    TabbarItem,
    NavBar,
    Icon,
    Swipe,
    SwipeItem,
    Rate,
    Search,
    Tab,
    Tabs,
    Sidebar,
    SidebarItem,
    IndexBar,
    IndexAnchor,
    Cell,
    CellGroup,
    Stepper,
    DropdownMenu,
    DropdownItem,
    TreeSelect,
    Form,
    Field,
    Popup,
    AddressList,
    Toast,
}
    from 'vant';
import 'vant/lib/index.css';

axios.interceptors.request.use((config: any): any => {
    showToast({
        type: 'loading',
        message: '加载中...',
        forbidClick: true,
        duration: 0
    })
    return config;
}, function (error) {
    closeToast();
    return Promise.reject(error);
})
axios.interceptors.response.use(function (response) {
    closeToast();
    return response;
}, function (error) {
    closeToast();
    return Promise.reject(error);
});

import 'lib-flexible/flexible'
const pinia = createPinia()
createApp(App)
    .use(router)
    .use(pinia)
    //vant4组件注册
    .use(Button)
    .use(Tabbar)
    .use(NavBar)
    .use(Icon)
    .use(TabbarItem)
    .use(Swipe)
    .use(SwipeItem)
    .use(Rate)
    .use(Search)
    .use(DropdownMenu)
    .use(DropdownItem)
    .use(Sidebar)
    .use(SidebarItem)
    .use(TreeSelect)
    .use(Form)
    .use(Field)
    .use(CellGroup)
    .use(Popup)
    .use(Tab)
    .use(Tabs)
    .use(IndexBar)
    .use(IndexAnchor)
    .use(Cell)
    .use(Stepper)
    .use(AddressList)
    .use(Toast)
    .mount('#app')
